<template>
  <Book :book="bookInfo" />
  <router-link to="/about">About</router-link>
</template>

<script>
import { defineComponent, reactive, toRefs, onMounted } from "vue";
import { useStore } from "@/store";
import Book from "@/components/Book.vue";

export default defineComponent({
  name: "home",

  components: {
    Book,
  },

  setup() {
    const store = useStore();
    const state = reactive({
      bookInfo: {
        title: "this is a book",
        author: "kevin",
        year: 2021,
      },
    });

    const onAdd = () => {
      store.$patch({
        count: ++store.count,
      });
    };

    const onReset = () => {
      store.$reset();
    };

    const onAction = () => {
      store.countThird();
    };

    onMounted(() => {});

    return {
      ...toRefs(state),
      store,
      onAdd,
      onReset,
      onAction,
    };
  },
});
</script>

<style lang="scss" scoped>
.title {
}
</style>